import { IPSAppDEACMode } from '../../app/dataentity/ipsapp-deacmode';
import { IPSAppDEDataSet } from '../../app/dataentity/ipsapp-dedata-set';
import { IPSAppDataEntity } from '../../app/dataentity/ipsapp-data-entity';
import { PSEditorImpl } from '../pseditor-impl';
import { IPSAutoComplete } from './ipsauto-complete';
import { IPSTextEditor } from './ipstext-editor';
import { IPSSysValueRule } from '../../valuerule/ipssys-value-rule';
import { IPSUIActionGroup } from '../../view/ipsuiaction-group';

export class PSAutoCompleteImpl extends PSEditorImpl implements IPSAutoComplete, IPSTextEditor {
  get aCMinChars(): number {
    return this.M.aCMinChars != null ? this.M.aCMinChars : 0;
  }

  get contextJOString(): string {
    return this.M.contextJOString;
  }

  get handlerType(): string {
    return this.M.handlerType;
  }

  get itemParamJO(): IModel {
    return this.M.itemParamJO;
  }

  get maxLength(): number {
    return this.M.maxLength;
  }

  get minLength(): number {
    return this.M.minLength != null ? this.M.minLength : 0;
  }

  protected psappdeacmode: IPSAppDEACMode | null = null;

  getPSAppDEACMode(): IPSAppDEACMode | null {
    if (this.psappdeacmode != null) return this.psappdeacmode;
    const value = this.M.getPSAppDEACMode;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.psappdeacmode = ipsappdataentity.findPSAppDEACMode(value);
    }
    return this.psappdeacmode;
  }

  get psAppDEACMode(): IPSAppDEACMode | null {
    return this.getPSAppDEACMode();
  }

  getPSAppDEACModeMust(): IPSAppDEACMode {
    const value = this.getPSAppDEACMode();
    if (value == null) {
      throw new Error('未指定应用实体自填模式对象');
    }
    return value;
  }

  protected psappdedataset: IPSAppDEDataSet | null = null;

  getPSAppDEDataSet(): IPSAppDEDataSet | null {
    if (this.psappdedataset != null) return this.psappdedataset;
    const value = this.M.getPSAppDEDataSet;
    if (value == null) {
      return null;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.psappdedataset = ipsappdataentity.findPSAppDEDataSet(value);
    }
    return this.psappdedataset;
  }

  get psAppDEDataSet(): IPSAppDEDataSet | null {
    return this.getPSAppDEDataSet();
  }

  getPSAppDEDataSetMust(): IPSAppDEDataSet {
    const value = this.getPSAppDEDataSet();
    if (value == null) {
      throw new Error('未指定应用实体结果集对象');
    }
    return value;
  }

  protected psappdataentity: IPSAppDataEntity | null = null;

  getPSAppDataEntity(): IPSAppDataEntity | null {
    if (this.psappdataentity != null) return this.psappdataentity;
    const value = this.M.getPSAppDataEntity;
    if (value == null) {
      return null;
    }
    this.psappdataentity = this.getPSModel4('app.dataentity.IPSAppDataEntity', value, 'getPSAppDataEntity') as IPSAppDataEntity;
    return this.psappdataentity;
  }

  get psAppDataEntity(): IPSAppDataEntity | null {
    return this.getPSAppDataEntity();
  }

  getPSAppDataEntityMust(): IPSAppDataEntity {
    const value = this.getPSAppDataEntity();
    if (value == null) {
      throw new Error('未指定应用实体对象');
    }
    return value;
  }

  protected pssysvaluerule: IPSSysValueRule | null = null;

  getPSSysValueRule(): IPSSysValueRule | null {
    if (this.pssysvaluerule != null) return this.pssysvaluerule;
    const value = this.M.getPSSysValueRule;
    if (value == null) {
      return null;
    }
    this.pssysvaluerule = this.getPSModel4('valuerule.IPSSysValueRule', value, 'getPSSysValueRule') as IPSSysValueRule;
    return this.pssysvaluerule;
  }

  get psSysValueRule(): IPSSysValueRule | null {
    return this.getPSSysValueRule();
  }

  getPSSysValueRuleMust(): IPSSysValueRule {
    const value = this.getPSSysValueRule();
    if (value == null) {
      throw new Error('未指定值规则');
    }
    return value;
  }

  protected psuiactiongroup: IPSUIActionGroup | null = null;

  getPSUIActionGroup(): IPSUIActionGroup | null {
    if (this.psuiactiongroup != null) return this.psuiactiongroup;
    const value = this.M.getPSUIActionGroup;
    if (value == null) {
      return null;
    }
    this.psuiactiongroup = this.getPSModel4('view.IPSUIActionGroup', value, 'getPSUIActionGroup') as IPSUIActionGroup;
    return this.psuiactiongroup;
  }

  get psUIActionGroup(): IPSUIActionGroup | null {
    return this.getPSUIActionGroup();
  }

  getPSUIActionGroupMust(): IPSUIActionGroup {
    const value = this.getPSUIActionGroup();
    if (value == null) {
      throw new Error('未指定相关界面行为组');
    }
    return value;
  }

  get paramJOString(): string {
    return this.M.paramJOString;
  }

  get enableAC(): boolean {
    return this.M.enableAC;
  }

  get forceSelection(): boolean {
    return this.M.forceSelection;
  }

  get showMaxLength(): boolean {
    return this.M.showMaxLength != null ? this.M.showMaxLength : false;
  }

  get showTrigger(): boolean {
    return this.M.showTrigger;
  }

  get cls(): string {
    return 'PSAutoCompleteImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSNavigateParamContainer' || cls == 'control.editor.IPSAutoComplete' || cls == 'control.editor.IPSTextEditor') return true;
    return super.instanceof(cls);
  }
}
